import axios from "axios";
import { IUser, IRecruit } from "../types";

interface BaseRes {
  stat: string;
  message: string;
}

interface companyReList extends BaseRes {
  result: IRecruit[];
}

interface similarJob extends BaseRes {
  result: IRecruit[];
}

interface findUser extends BaseRes {
  data: IUser;
}

interface DetailRes extends BaseRes {
  result: IRecruit;
}

// 职位详细信息
export async function recruitDetail(id: string) {
  const result = await axios.post<DetailRes>("/api/recruit/detail", { id: id });
  return result.data;
}

// 招聘人详细信息
export async function interviewer(id: string) {
  const result = await axios.post<findUser>("/api/user/front/userInfo", {
    id: id,
  });
  return result.data;
}

// 请求高德地图
export async function location(key: string, arrdess: string) {
  const result = await axios.post(
    "https://restapi.amap.com/v3/geocode/geo?address=" + arrdess + "&key=" + key
  );
  return result;
}

// 相似职位
export async function similarjob(key: string) {
  const result = await axios.post<similarJob>("/api/recruit/home/keyword", {
    keyWords: key,
  });
  return result.data;
}

// 公司热招职位
export async function RecruitLi(companyId: string) {
  const result = await axios.post<companyReList>("/api/recruit/hotRecruit", {
    companyId,
  });
  return result.data;
}
